//
//  ViewController.swift
//  2048Demo
//
//  Created by wpsd on 2017/3/24.
//  Copyright © 2017年 wpsd. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        setupButton()    
        // 创建背景图片视图并设置图片
           let backgroundImageView = UIImageView(frame: view.bounds)
           backgroundImageView.image = UIImage(named: "2048")
           backgroundImageView.contentMode = .scaleToFill // 或者选择其他适合的模式
        
        // 将背景图片视图插入到视图层次的底部，确保它不会盖其他视图，如按钮等
           view.insertSubview(backgroundImageView, at: 0)
        
        
    }
    
    private func setupButton() {
        
        let btn = UIButton(frame: CGRect(x: 0, y: 0, width: 200, height: 40))
        btn.setTitleColor(UIColor.black, for: .normal)
        btn.setTitle("Start  game", for: .normal)
        btn.setTitleColor(UIColor(red: 1.0, green: 0.55, blue: 0.0, alpha: 1.0), for: .normal)  // 设置深橙色文字
           btn.titleLabel?.font = UIFont(name: "Marker Felt", size: 32)
        btn.center = CGPoint(x: view.center.x, y: view.center.y+100)
        btn.addTarget(self, action: #selector(btnClick(sender:)), for: .touchUpInside)
        view.addSubview(btn)
        
    }
    
    @objc private func btnClick(sender: UIButton) {
        
        present(ChoiceView(), animated: true, completion: nil)
        
    }

}

